package cn.wolfcode.web.Interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginInterceptor implements HandlerInterceptor {
    //前置拦截
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Object emp = request.getSession().getAttribute("USER_IN_SESSION");
        if (emp != null ){
            return true;
        }
        //表示还没登录滚回去登录
        response.sendRedirect("/login.html");
        return false;
    }
}
